package com.yohann.designPattern.iterator.college;

import com.yohann.designPattern.iterator.iterator.ComputerCollegeIterator;
import com.yohann.designPattern.iterator.department.Department;

import java.util.Iterator;

/**
 * <p>
 * 计算机学院
 * </p>
 *
 * @author Yohann
 * @since 2021/2/12 16:09
 */
public class ComputerCollege implements College {
    private Department[] departments;
    private int size = 0;

    public ComputerCollege() {
        this.departments = new Department[5];
        addDepartment("Java", "Java");
        addDepartment("PHP", "PHP");
        addDepartment("C", "C");
        addDepartment("C++", "C++");
        addDepartment("C#", "C#");
    }

    @Override
    public String getName() {
        return "computer";
    }

    @Override
    public void addDepartment(String name, String description) {
        Department department = new Department(name, description);
        departments[size] = department;
        size++;
    }

    @Override
    public Iterator createIterator() {
        return new ComputerCollegeIterator(departments);
    }
}